Il existe de multiples options informatiques pour faire de la stylométrie. Nous nous proposons, dans ce cours, d’utiliser le package R nommé Stylo, mais d’autres options existent comme FactoMineR. Ce package étant développé par des français de l’agrocampus de Rennes, notons qu’une importante documentation en français est disponible, et permettra aux personnes intéressées de continuer leur apprentissage de la stylométrie.
Ce cours est disponible en ligne avec le corpus que nous utilisons dans ce notebook: on peut le trouver sur notre Github. Il est distribué avec une licence CC-BY.
Le corpus est constitué de pièces de théâtre du XVIIe siècle, disponibles sur le site www.theatre-classique.fr, rassemblées par J.-B. Camps (Ecole des Chartes) et adaptées par nous-mêmes pour correspondre aux besoins de ce cours.
Stylo est développé par Maciej Eder (Cravocie), Mike Kestmont (Anvers) et Jan Rybicki (Cravocie). On trouvera de nombreuses ressources sur le site de leur groupe de computational stylistics et sur leur GitHub, qui contient un repo consacré au package stylo avec de nombreuses informations sur son fonctionnement.
Pour ceux qui voudraient s’entraîner avec d’autres données que celles fournies pour le cours, un repo avec 100 romans anglais se trouve sur leur GitHub (cliquez sur le bouton vert Clone or download à droite pour télécharger le tout au format zip).
##1.2 À propos du corpus
Stylo a besoin de savoir où chercher les données (pour nous il s’agit de notre corpus) qu’il va utiliser, et celles-ci doivent impérativement obéir à trois règles simples:
corpus ne doit contenir que les fichiers du corpus: tout autre document se retrouverait analysé avec le reste, et perturberait les résultats.txt, soit en XML, soit en HTML.##1.4 Préparer la session de travail
Nous devons préparer la session de travail, en désignant à R le fichier de notre ordinateur à partir duquel nous allons travailler pour qu’il trouve notre fichier corpus, et qu’il y sauvegarde nos résultats.
Pour indiquer où se trouve le fichier de travail, deux solutions sont possibles:
Session>Set Working Directory>Choose DirectoryR avec la commande setwd (pour Set working directory), qui s’utilise de cette manière.setwd("~/GitHub/Cours_2020_UniGE/Cours_Geneve_5")
#je charge les données que l'enseignant a préparé pour éviter les problèmes
#load("Cours_Geneve_5.RData")
On peut vérifier que le chemin vers le dossier de travail a bien été pris en compte avec une autre commande: getwd (pour Get working directory):
getwd()
[1] "/Users/gabaysimon/GitHub/Cours_2020_UniGE/Cours_Geneve_5"
Tout est en ordre? Avançons! installons stylo()
if(!require("stylo")){
install.packages("stylo")
library(stylo)
}
Loading required package: stylo
### stylo version: 0.6.9 ###
If you plan to cite this software (please do!), use the following reference:
Eder, M., Rybicki, J. and Kestemont, M. (2016). Stylometry with R:
a package for computational text analysis. R Journal 8(1): 107-121.
<https://journal.r-project.org/archive/2016/RJ-2016-007/index.html>
To get full BibTeX entry, type: citation("stylo")
Il ne nous reste plus qu’à lancer stylo, avec la commande… stylo()!
#2. Le data clustering
##2.1 Ouvrir stylo
L’application Stylo peut être utilisée en ligne de commande, mais aussi avec une GUI (graphical user interface, en français “interface graphique”). Si vous voulez avoir un premier aperçu, retirez le # au début de la ligne infra et cliquez sur Run.
#stylo()
##2.2 Une première analyse de cluster
Nous allons désormais tenter une première analyse de cluster. Le data clustering (ou “partitionnement de données” en français) cherche à diviser un ensemble de données en différents “groupes” homogènes selon des caractéristiques qu’ils partagent. Ces groupes (dans notre cas des pièces de théâtre) sont formés à partir de calculs qui déterminent leur proximité (similarité ou distance).
Note importante Afin de gagner du temps, nous avons directement paramétré le formulaire de la GUI, mais la commande stylo() vide, comme précédemment (cf. 2.1), suffirait si les bonnes cases étaient bien cochées.
Lorsque vous appuyerez sur Run observez la console: une série de messages vous avertit de ce qu’il se passe.
stylo(gui=TRUE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 100, mfw.incr=100,
analysis.type = "CA", distance.measure = "manhattan",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
Calculating Manhattan distances...
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
Reprenons le processus dans ses grandes lignes:
loading…: Une fois la commande lancée, chaque texte est est chargé.Total nr. of samples…: On nous avertit du nombre de textes dans le corpus, qui sont tous éclatés en tokens (ici des mots).combining frequencies…: Le nombre d’occurrence de chaque token est calculé pour chaque document du corpus, pour former un tableau de fréquences.Calculating Manhattan distance: ces tableaux de fréquences permettent de voir si certains tokens reviennent de manière équivalente dans d’autres documents, et de produire les clusters. Nous allons revenir plusieurs fois sur ce point par la suite.Regardons maintenant le graphique qui nous est donné. Il s’agit d’un dendogramme, qui est accompagné de quelques informations en bas de page (100 MFW Culled @ 0% Manhattan distance):
100 MFW Nous avons utilisé les 100 mots les plus fréquents. Pendant le traitement des données, Stylo a généré quelques fichiers qui nous permettent de voir quels sont ces mots, ainsi que leur fréquence. Allez dans votre dossier de travail, et regardez les documents wordlist.txt et table_with_frequencies.txt. Nous reviendrons plus tard sur ces données.Culled @ 0%: Le culling est à 0%, ce qui signifie que les mots les plus fréquents peuvent être absents de certains textes. Un culling à 100% signifierait que nous ne retiendrions que les mots les plus fréquents retenus dans tous les textes.Manhattan distance: Nous avons utilisé la distance dite “de Manhattan”, mais il en existe d’autres:
##2.3 Contrôler la fiabilité des résultats: répéter l’opérations avec d’autres paramètres
Nous avons obtenu un cluster: il est plausible, mais est-il fiable? Nous avons besoin d’encore plus de certitudes… Une première solution est de répéter le même clacul, en augmentant le nombre des mots les plus fréquents: passons de 100 à 1000.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 1000, mfw.max = 100, mfw.incr=100,
analysis.type = "CA", distance.measure = "manhattan",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
Calculating Manhattan distances...
MFW used:
1000
Processing metadata...
Assigning plot colors according to file names...
Les résultat est déjà moins net… À quel moment du bruit a-t-il commencé à perturber la formation des groupes? Afin de le savoir, nous pouvons demander à Stylo de répéter l’analyse de cluster un certain nombre de fois entre 100 et 1000.
Demandons à Stylo de refaire le calculs dix fois, en incrémentant de 100 à chaque fois.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 1000, mfw.incr=100,
analysis.type = "CA", distance.measure = "manhattan",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
Calculating Manhattan distances...
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
300
Processing metadata...
Assigning plot colors according to file names...
400
Processing metadata...
Assigning plot colors according to file names...
500
Processing metadata...
Assigning plot colors according to file names...
600
Processing metadata...
Assigning plot colors according to file names...
700
Processing metadata...
Assigning plot colors according to file names...
800
Processing metadata...
Assigning plot colors according to file names...
900
Processing metadata...
Assigning plot colors according to file names...
1000
Processing metadata...
Assigning plot colors according to file names...
Function call:
stylo(gui = FALSE, corpus.dir = "corpus", corpus.format = "xml.drama", corpus.lang = "French", analyzed.features = "w", mfw.min = 100, mfw.max = 1000, mfw.incr = 100, analysis.type = "CA", distance.measure = "manhattan", pca.visual.flavour = "classic")
Depending on your chosen options, some results should have been written
into a few files; you should be able to find them in your current
(working) directory. Usually, these include a list of words/features
used to build a table of frequencies, the table itself, a file containing
recent configuration, etc.
Advanced users: you can pipe the results to a variable, e.g.:
my.boss.will.love.it = stylo()
this will create a class "my.boss.will.love.it" containing some presumably
interesting stuff. The class created, you can type, e.g.:
summary(my.boss.will.love.it)
to see which variables are stored there and how to use them.
for suggestions how to cite this software, type: citation("stylo")
Difficile cependant de comparer facilement 10 dendogrammes… Et comment faire pour 20, 30 ou 1000 dendogrammes?
##2.4 Contrôler autrement la fiabilité des résultats: le consensus tree
Il est possible de représenter graphiquement la somme de ces informations: il s’agit du concensus tree (“arbre de consensus”, en français). Voyons la forme de ce graphique avec les résultats que nous venons d’obtenir.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 1000, mfw.incr=100,
analysis.type = "BCT", consensus.strength = 0.5, distance.measure = "manhattan",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
Calculating Manhattan distances...
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
200
Processing metadata...
Assigning plot colors according to file names...
300
Processing metadata...
Assigning plot colors according to file names...
400
Processing metadata...
Assigning plot colors according to file names...
500
Processing metadata...
Assigning plot colors according to file names...
600
Processing metadata...
Assigning plot colors according to file names...
700
Processing metadata...
Assigning plot colors according to file names...
800
Processing metadata...
Assigning plot colors according to file names...
900
Processing metadata...
Assigning plot colors according to file names...
1000
Processing metadata...
Assigning plot colors according to file names...
C’est l’occasion de changer dans la méthode de calcul de distance, pour vérifier les performances de chacune. Nous utilisions jusqu’à présent la “distance de Manhattan”, essayons cette fois avec une distance euclidienne.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 1000, mfw.incr=100,
analysis.type = "BCT", consensus.strength = 0.5, distance.measure = "euclidean",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
Calculating Euclidean distances...
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
200
Processing metadata...
Assigning plot colors according to file names...
300
Processing metadata...
Assigning plot colors according to file names...
400
Processing metadata...
Assigning plot colors according to file names...
500
Processing metadata...
Assigning plot colors according to file names...
600
Processing metadata...
Assigning plot colors according to file names...
700
Processing metadata...
Assigning plot colors according to file names...
800
Processing metadata...
Assigning plot colors according to file names...
900
Processing metadata...
Assigning plot colors according to file names...
1000
Processing metadata...
Assigning plot colors according to file names...
Et maintenant avec une distance typique de la stylométrie: la distance de Burrows (du nom de son inventeur, John Burrows), aussi appelée “classic delta”.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 1000, mfw.incr=100,
analysis.type = "BCT", consensus.strength = 0.5, distance.measure = "delta",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
Calculating classic Delta distances...
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
200
Processing metadata...
Assigning plot colors according to file names...
300
Processing metadata...
Assigning plot colors according to file names...
400
Processing metadata...
Assigning plot colors according to file names...
500
Processing metadata...
Assigning plot colors according to file names...
600
Processing metadata...
Assigning plot colors according to file names...
700
Processing metadata...
Assigning plot colors according to file names...
800
Processing metadata...
Assigning plot colors according to file names...
900
Processing metadata...
Assigning plot colors according to file names...
1000
Processing metadata...
Assigning plot colors according to file names...
Comparez les résultats obtenus avec ces différentes méthode de calcul. Réflechissez à ce dilemme: la différence entre les résultats signifie-t-elle
##2.5 S’appuyer sur d’autres expériences
En plus de cette approche empirique, il est important de s’appuyer sur des études qui précisent les paramètres les plus efficaces. Selon Evert, Proisl, Jannidi, Reger, Pielström, Schöch, Vitt (2017), 5000 mots MFW avec cosine delta serait le plus efficace (y compris pour le français):
100% center
Evert, Proisl, Jannidi, Reger, Pielström, Schöch, Vitt, " Understanding and explaining Delta measures for authorship attribution",Digital Scholarship in the Humanities, Volume 32, December 2017, Pages ii4–ii16, https://doi.org/10.1093/llc/fqx023
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min =5000, mfw.max = 100, mfw.incr=100,
analysis.type = "CA", distance.measure = "wurzburg",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
MFW used:
5000
Processing metadata...
Assigning plot colors according to file names...
#3. Fonctionnement de stylo
Les données utilisées pendant l’analyse stylométrique sont accessibles: pour les voir, nous devons donc créer une variable et les stocker. Appelons la variable “resultats”, qui s’utilise ainsi:
resultats <- stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 5000, mfw.max = 100, mfw.incr=100,
analysis.type = "CA", distance.measure = "wurzburg",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
MFW used:
5000
Processing metadata...
Assigning plot colors according to file names...
Voyons ce que nous donne cette variable:
resultats
Function call:
stylo(gui = FALSE, corpus.dir = "corpus", corpus.format = "xml.drama", corpus.lang = "French", analyzed.features = "w", mfw.min = 5000, mfw.max = 100, mfw.incr = 100, analysis.type = "CA", distance.measure = "wurzburg", pca.visual.flavour = "classic")
Depending on your chosen options, some results should have been written
into a few files; you should be able to find them in your current
(working) directory. Usually, these include a list of words/features
used to build a table of frequencies, the table itself, a file containing
recent configuration, etc.
Advanced users: you can pipe the results to a variable, e.g.:
important.contribution = stylo()
this will create a class "important.contribution" containing some presumably
interesting stuff. The class created, you can type, e.g.:
summary(important.contribution)
to see which variables are stored there and how to use them.
for suggestions how to cite this software, type: citation("stylo")
Les données sont nombreuses: on nous redirige vers une sorte de portail avec les différentes données collectées, que l’on peut consulter avec le code suivant:
summary(resultats)
Function call:
stylo(gui = FALSE, corpus.dir = "corpus", corpus.format = "xml.drama", corpus.lang = "French", analyzed.features = "w", mfw.min = 5000, mfw.max = 100, mfw.incr = 100, analysis.type = "CA", distance.measure = "wurzburg", pca.visual.flavour = "classic")
Available variables:
distance.table final distances between each pair of samples
features features (e.g. words, n-grams, ...) applied to data
features.actually.used features (e.g. frequent words) actually analyzed
frequencies.0.culling frequencies of words/features accross the corpus
list.of.edges edges of a network of stylometric similarities
table.with.all.freqs frequencies of words/features accross the corpus
table.with.all.zscores z-scored frequencies accross the corpus
These variables can be accessed by typing e.g.:
resultats$distance.table
Plusieurs variables sont diponibles. features permet d’afficher la liste des mots par ordre de fréquence:
resultats$features
---------------------------------------------------
features (e.g. words, n-grams, ...) applied to data
---------------------------------------------------
[1] de et que le vous je
[7] l la à un il en
[13] est d qu ce ne qui
[19] les pour mon me n si
[25] des on a j m son
[31] plus mais ma une pas du
[37] votre elle dans par bien moi
[43] sa nous au s tout lui
[49] sans fait se ai tu point
[55] c mes cette ses vos amour
[61] même peut sur où coeur ou
[67] ces avec tous être faire scène
[73] comme trop faut roi t voir
[79] aux dont y leur rien sont
[85] suis yeux te ont âme non
[91] tant ton ciel ils quand enfin
[97] père grand madame don cet donc
[103] dieux nos quoi autre moins peu
[109] quelque jamais quel ô ta mort
[115] veux ici honneur deux puis sang
[121] notre contre avoir jour vois esprit
[127] soit mal toi sort toujours dit
[133] temps aussi doit après ainsi seigneur
[139] encore gloire veut avez aime prince
[145] toute dire là main peine assez
[151] leurs fois fort va seul tes
[157] oui vie donne fille encor fils
[163] sais sous était ni nom bras
[169] mieux crime dessein fais vient reine
[175] raison état vu déjà dois dieu
[181] homme pouvoir frère ah ha fut
[187] amant hélas quelle rendre première discours
[193] lieu donner voeux aujourd hui foi
[199] mains juste malheur beau ait dis
[205] heureux autres lieux jusqu vertu pu
[211] voit crois monsieur celui chez fortune
[217] grâce jours entre puisque flamme coup
[223] viens bon avait haine parler autant
[229] eux mourir trouve doux espoir doute
[235] courage devoir douleur grands belle prendre
[241] chose moment porte êtes phèdre pleurs
[247] toutes devant objet tel vais cour
[253] faites sujet force parle rois effet
[259] vrai acte courroux mille car maître
[265] soins reste bonheur loin eût terre
[271] part seulement allons depuis pourquoi malheureux
[277] puisse monde soin laisse peuple sera
[283] trône cher femme sait colère as
[289] bruit digne hippolyte croire seule v
[295] voulez ardeur extrême maux cela coups
[301] vers voix font nuit secret faveur
[307] fureur plutôt pris repos allez mère
[313] vain ceux corps ii mérite triste
[319] avant époux feu peur puisqu ayant
[325] cependant hé lois sens demande destin
[331] trouver ennemis iii soeur voyez victoire
[337] place rend traître fit malgré souffrir
[343] funeste bientôt hymen lorsque tête coupable
[349] iv ose semble premier celle cruel
[355] prix gens aimer dessus éclat oeil
[361] secours trépas donné venger alors heure
[367] perte joie serait voilà mettre respect
[373] quelques rang haut longtemps ennemi perdre
[379] choix empire généreux cent personne rodrigue
[385] ami chercher honte paraître vainqueur esther
[391] été fin bas beaucoup loi aurait
[397] servir horreur nature puissance sire amitié
[403] grande voici beauté feux savoir souvent
[409] envie sein afin aller aura combat
[415] justice plaisir pouvez venir bonne fasse
[421] sanche suivre théâtre vengeance avais droit
[427] fidèle ordre bouche comment craindre voulu
[433] crainte dedans malheurs pitié mis partout
[439] chimène crains larmes thésée vouloir armes
[445] désirs visage voyant zèle comte intérêt
[451] vue choses couronne effort estime garde
[457] hommes rigueur valeur croit monstre offense
[463] silence cieux cours dites passion princesse
[469] sortir trouble vivre adieu glorieux mot
[475] sauver aurais laissez pays telle jeune
[481] besoin coeurs lâche montrer quels sentiments
[487] illustre esprits étant palais sceptre toutefois
[493] appas arcas front jaloux racine amis
[499] maîtresse paix sorte avis cause imprimer
[505] infante pourrait rival su chacun entendre
[511] savez alcandre amoureux cacher mépris orgueil
[517] dès noble étais fera grandeur rome
[523] trois biens césar chaque conseil plaît
[529] retour soleil attendre dernier fatal fers
[535] parmi tiens univers aucun chère combien
[541] eut près vit perfide punir abord
[547] art connaître défendre laisser passe sommes
[553] ans charmes désir entends nouveau parlez
[559] sois soupirs cherche innocence prend tient
[565] très elles gardes humeur léonore lucipe
[571] mien prends succès desseins eu maintenant
[577] connais cru indigne orante perdu peux
[583] titus traits appelle injuste naissance offre
[589] saurait cesse ingrat maison pieds regret
[595] sujets attends comédie croyez épée faible
[601] instant juge outrage paris permis action
[607] étrange propos supplice venez air cruelle
[613] jusques pensée tantôt amants demander demeure
[619] constance espère fer montre pense péril
[625] souffre suit affaire ailleurs auprès aventure
[631] beaux douleurs met nouvelle plaire régner
[637] soient tragédie ville aimable aurai histoire
[643] milieu penser pourtant privilège propre rage
[649] transports auteur excès mémoire quelqu attend
[655] bons es faiblesse lit moindre paraît
[661] plein présent vi arrêt écoute héros
[667] i liberté peuvent plaisirs soi audace
[673] efforts espérance mots odieux presse regards
[679] service tourment vôtre aimé cache oblige
[685] recevoir règne rendu songe violence bonté
[691] chemin douceur innocent légitime parole passer
[697] plaindre port porter vérité vertus achille
[703] âge avons ensemble espérer pièce sert
[709] songez vis antoine clitophon faux guerre
[715] pourrais remède aussitôt avecque bout obéir
[721] ôte tomber trouvé verra voudrais andromède
[727] dernière devez louis quitter témoins vaut
[733] aveugle bérénice cède désespoir fuite manque
[739] mortel parti promis rare rends souvenir
[745] suffit adore aimez donnez enfants importe
[751] jason mêmes ombre ôter présence soyez
[757] beautés ferai foudre long lorsqu moyen
[763] perd qualité sage tombeau victime apparence
[769] aricie clarigène conseils côté effroi favorable
[775] fruit juifs médée occasion pedre prison
[781] sensible souffrez tour agir craignez effets
[787] exemple misérable or tyran affront choeur
[793] craint ennui fou mauvais nombre parce
[799] phinée pourra prêt tôt vaincre conserver
[805] contraire hôtel livre naître pareil prête
[811] suite taire tenir vont abandonne barbare
[817] carlos clindor haïr importune isabelle japhet
[823] âmes arrête capable chambre demain entretien
[829] erreur lumière pouvait prompt puissant reçu
[835] regarde secrets adresse aisément davantage faisant
[841] faute forte mari ouvre partir prenez
[847] venu amène cris esclave faits hercule
[853] hors infidèle mienne périr querelle quoique
[859] sosie soupçons tirer véritable criminel défense
[865] elvire garder haman jette juger meure
[871] orage ouvrage sacrifice tort touche tue
[877] armée brute famille haute lettre majesté
[883] poison quitte sentiment tendresse apprendre attraits
[889] danger ferme fût genoux infâme monseigneur
[895] mortels obstacle presque seront tombe alcmène
[901] bernard certain désormais justes messieurs offrir
[907] ressentiment trait vii actions amphitryon content
[913] douter empêcher entière exploits fameux faveurs
[919] finir menace morts obliger oreille quatre
[925] raisons rendez résoudre serais souci surtout
[931] accord autel écouter faisons jalousie mérité
[937] obéissance oenone perds vaine appui brave
[943] lors mer monarque passions satisfait arrive
[949] autrefois bontés connaît destinée fâcheux fatale
[955] hyménée mériter passé peines prie refuse
[961] rompre serez soldats témoin voyons autorité
[967] certes change dirai disgrâce fus iphigénie
[973] jupiter ouvrir petit pleine six temple
[979] tristes tristesse usage affreux attente bois
[985] cavalier créuse dû enfers ennuis étaient
[991] états feinte heur pied plainte soir
[997] approche arrêter justement marine
(total number of elements: 5000)
Ces mots sont classés du plus au moins fréquent dans le corpus. Nous pouvons voir leur fréquence par texte avec la variable table.with.all.freqs
resultats$table.with.all.freqs
------------------------------------------------
frequencies of words/features accross the corpus
------------------------------------------------
de et que le vous je l
CORNEILLEP_ANDROMEDE 3.3951384 2.8881046 1.8740369 1.6851419 1.7497639 1.0488641 1.6553164
CORNEILLEP_CID 3.1328205 2.7110946 1.7286125 1.7795903 0.8805265 1.5617759 1.8166651
CORNEILLEP_ILLUSIONCOMIQUE 3.3480808 2.5887839 1.7577424 1.5006577 1.745785 1.9191678 1.4767428
CORNEILLEP_MEDEE 3.602332 3.0193311 1.9515189 1.2887389 1.0923596 1.5526235 1.5219392
DURYER_CLARIGENE 2.470869 2.5831812 2.470869 1.8180542 2.0847957 1.965464 1.6706444
DURYER_CLITOPHON 3.3655844 2.3683742 2.3505669 1.7213747 0.9259809 1.5967235 1.8222829
DURYER_DYNAMIS 2.5321281 3.2563712 2.2326291 2.0638205 1.6663036 1.7370943 1.7262034
DURYER_ESTHER 2.9122765 2.5985557 2.0894992 2.3262697 1.8290517 1.586362 1.562685
MOLIERE_AMPHITRYON 3.3137427 2.7197699 2.050769 1.4442916 1.5068151 2.1758159 1.4317869
MOLIERE_DOMGARCIEDENAVARRE 3.0433769 2.5303172 2.2854478 1.329291 2.1513526 1.6791045 1.5625
... ... ... ... ... ... ...
la à un il
CORNEILLEP_ANDROMEDE 1.5658398 1.8292986 1.307352 1.3272357 ...
CORNEILLEP_CID 1.3207897 1.8954491 1.3995736 1.3485958 ...
CORNEILLEP_ILLUSIONCOMIQUE 1.2914026 1.4707641 1.53653 1.6321894 ...
CORNEILLEP_MEDEE 1.5771709 2.1172139 1.3930654 1.1660018 ...
DURYER_CLARIGENE 1.2003369 1.2564931 1.7759371 1.488137 ...
DURYER_CLITOPHON 1.5848519 1.317742 1.478008 1.0268891 ...
DURYER_DYNAMIS 1.8296667 1.3232411 1.8351122 1.6118493 ...
DURYER_ESTHER 1.5330887 1.3318338 1.7698591 1.4561383 ...
MOLIERE_AMPHITRYON 1.0941603 1.6631237 1.3942729 1.3817682 ...
MOLIERE_DOMGARCIEDENAVARRE 0.9736474 1.8948228 1.7257463 1.4109142 ...
... ... ... ... ...
(total number of rows/columns: 28/5000)
On peut voir ces scores z-transformés avec $table.with.all.zscores
resultats$table.with.all.zscores
---------------------------------------
z-scored frequencies accross the corpus
---------------------------------------
de et que le vous je
CORNEILLEP_ANDROMEDE 0.6842816 0.472655 -0.2652929 -0.4254443 -0.031686 -1.4494191
CORNEILLEP_CID -0.0100579 -0.0027929 -0.6987936 -0.1466652 -1.3067341 -0.4017725
CORNEILLEP_ILLUSIONCOMIQUE 0.559723 -0.3313188 -0.6119591 -0.9699783 -0.0375225 0.3282174
CORNEILLEP_MEDEE 1.2327103 0.8251286 -0.0343241 -1.5954895 -0.9960049 -0.4204667
DURYER_CLARIGENE -1.7622027 -0.3463675 1.513825 -0.0331331 0.4597582 0.4227796
DURYER_CLITOPHON 0.6060539 -0.9233382 1.1552121 -0.3184976 -1.2400589 -0.3303904
DURYER_DYNAMIS -1.6000537 1.461817 0.8036471 0.6922844 -0.1541104 -0.0436763
DURYER_ESTHER -0.5938241 -0.3050718 0.3769864 1.4669438 0.084618 -0.3515541
MOLIERE_AMPHITRYON 0.468832 0.0205089 0.2615342 -1.1363515 -0.3880575 0.8524335
MOLIERE_DOMGARCIEDENAVARRE -0.2468096 -0.4883602 0.9610963 -1.4757935 0.5573877 -0.1621233
... ... ... ... ... ...
l la à un il
CORNEILLEP_ANDROMEDE 0.0592382 -0.0339873 1.015182 -0.4852049 -0.1214816 ...
CORNEILLEP_CID 0.9072204 -0.7548753 1.2611529 -0.0633864 -0.0176195 ...
CORNEILLEP_ILLUSIONCOMIQUE -0.8792708 -0.8413261 -0.317976 0.5630468 1.3613342 ...
CORNEILLEP_MEDEE -0.641737 -0.0006535 2.0857528 -0.0931551 -0.9054696 ...
DURYER_CLARIGENE 0.1397958 -1.1092229 -1.1147115 1.6580865 0.6608897 ...
DURYER_CLITOPHON 0.9367451 0.0219424 -0.8869661 0.2953693 -1.5818956 ...
DURYER_DYNAMIS 0.4317912 0.7421382 -0.8665185 1.9287511 1.2624317 ...
DURYER_ESTHER -0.4275942 -0.1303346 -0.834568 1.630286 0.5052981 ...
MOLIERE_AMPHITRYON -1.1155403 -1.4215731 0.3972849 -0.087632 0.1436787 ...
MOLIERE_DOMGARCIEDENAVARRE -0.4285664 -1.7760978 1.258824 1.4285154 0.2853992 ...
... ... ... ... ... ...
(total number of rows/columns: 28/5000)
Ces résultats permettent d’évaluer la distance entre chacun des textes de notre corpus. Cette fois les résultats sont accessibles avec le nom de notre variable suivi de $distance.table
resultats$distance.table
--------------------------------------------
final distances between each pair of samples
--------------------------------------------
CORNEILLEP_ANDROMEDE CORNEILLEP_CID CORNEILLEP_ILLUSIONCOMIQUE
CORNEILLEP_ANDROMEDE 0 1.0009417 0.9943957
CORNEILLEP_CID 1.0009417 0 0.9711001
CORNEILLEP_ILLUSIONCOMIQUE 0.9943957 0.9711001 0
CORNEILLEP_MEDEE 0.9916627 0.9460653 0.9472041
DURYER_CLARIGENE 1.0603433 1.0389668 1.0658526
DURYER_CLITOPHON 1.0171782 1.057457 1.0131517
DURYER_DYNAMIS 1.0533041 1.0179688 1.060149
DURYER_ESTHER 1.0369347 1.0302385 1.0973139
MOLIERE_AMPHITRYON 1.05929 1.073594 1.013192
MOLIERE_DOMGARCIEDENAVARRE 1.0073869 1.0103043 1.0501424
... ... ...
CORNEILLEP_MEDEE DURYER_CLARIGENE DURYER_CLITOPHON DURYER_DYNAMIS
CORNEILLEP_ANDROMEDE 0.9916627 1.0603433 1.0171782 1.0533041
CORNEILLEP_CID 0.9460653 1.0389668 1.057457 1.0179688
CORNEILLEP_ILLUSIONCOMIQUE 0.9472041 1.0658526 1.0131517 1.060149
CORNEILLEP_MEDEE 0 1.0380353 1.0169681 1.0561129
DURYER_CLARIGENE 1.0380353 0 0.8605236 0.9177383
DURYER_CLITOPHON 1.0169681 0.8605236 0 0.9836259
DURYER_DYNAMIS 1.0561129 0.9177383 0.9836259 0
DURYER_ESTHER 1.0064069 0.9301051 0.9741543 0.8451089
MOLIERE_AMPHITRYON 1.0647345 1.0717888 1.0964716 1.0807069
MOLIERE_DOMGARCIEDENAVARRE 1.0141992 1.0344084 1.0954863 1.0027317
... ... ... ...
DURYER_ESTHER MOLIERE_AMPHITRYON MOLIERE_DOMGARCIEDENAVARRE
CORNEILLEP_ANDROMEDE 1.0369347 1.05929 1.0073869
CORNEILLEP_CID 1.0302385 1.073594 1.0103043
CORNEILLEP_ILLUSIONCOMIQUE 1.0973139 1.013192 1.0501424
CORNEILLEP_MEDEE 1.0064069 1.0647345 1.0141992
DURYER_CLARIGENE 0.9301051 1.0717888 1.0344084
DURYER_CLITOPHON 0.9741543 1.0964716 1.0954863
DURYER_DYNAMIS 0.8451089 1.0807069 1.0027317
DURYER_ESTHER 0 1.1242496 1.0192903
MOLIERE_AMPHITRYON 1.1242496 0 0.9480107
MOLIERE_DOMGARCIEDENAVARRE 1.0192903 0.9480107 0
... ... ...
MOLIERE_MISANTHROPE
CORNEILLEP_ANDROMEDE 1.0644665 ...
CORNEILLEP_CID 1.0967865 ...
CORNEILLEP_ILLUSIONCOMIQUE 1.0286613 ...
CORNEILLEP_MEDEE 1.0892613 ...
DURYER_CLARIGENE 1.0723518 ...
DURYER_CLITOPHON 1.1228778 ...
DURYER_DYNAMIS 1.0995535 ...
DURYER_ESTHER 1.0901811 ...
MOLIERE_AMPHITRYON 0.8437953 ...
MOLIERE_DOMGARCIEDENAVARRE 0.8770485 ...
... ...
(total number of rows/columns: 28/28)
C’est donc à partir de ces fréquences, puis de ces distances que nous obtenons les dendogrammes que nous avons vus précédemment.
#4. D’autres visualisations
##4.1 Principal component analysis
Un autre mode de visualisation est le principal component analysis (“Analyse en composantes principales” en français), qui permet lui aussi de spatialiser les résultats, selon une autre éthode de calcul.
###4.1.1 Principal component analysis classique
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 5000, mfw.max = 100, mfw.incr=100,
analysis.type = "PCV", distance.measure = "wurzburg",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
MFW used:
5000
Processing metadata...
Assigning plot colors according to file names...
###4.1.2 Principal component analysis (avec les mots en superposition)
Il est possible de superposer les tokens (ici les mots) aux labels, afin de comprendre sur quelles données lexicales s’appuie la spatialisation.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 5000, mfw.max = 100, mfw.incr=100,
analysis.type = "PCV", distance.measure = "wurzburg",
pca.visual.flavour = "loadings")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
MFW used:
5000
Processing metadata...
Assigning plot colors according to file names...
On le voit, la plupart des tokens ayant des fréquences très faible, on se retrouve avec un “tas” de mots au centre, ce qui rend les données illisibles… Comment faire?
###4.1.3 Principal component analysis: les classes
Nous avons vu au cours précédent qu’il est important de contrôler la significativité des axes produits: nous ne pouvons cependant pas le faire avec stylo(), et il faut se tourner vers un autre pasckage: FactoMineR.
La première étape est de récupérer les fréquences qui nous intéressent pour les réutiliser plus tard:
#Je prends les fréquences par texte produites par stylo
resultats$table.with.all.freqs
------------------------------------------------
frequencies of words/features accross the corpus
------------------------------------------------
de et que le vous je l
CORNEILLEP_ANDROMEDE 3.3951384 2.8881046 1.8740369 1.6851419 1.7497639 1.0488641 1.6553164
CORNEILLEP_CID 3.1328205 2.7110946 1.7286125 1.7795903 0.8805265 1.5617759 1.8166651
CORNEILLEP_ILLUSIONCOMIQUE 3.3480808 2.5887839 1.7577424 1.5006577 1.745785 1.9191678 1.4767428
CORNEILLEP_MEDEE 3.602332 3.0193311 1.9515189 1.2887389 1.0923596 1.5526235 1.5219392
DURYER_CLARIGENE 2.470869 2.5831812 2.470869 1.8180542 2.0847957 1.965464 1.6706444
DURYER_CLITOPHON 3.3655844 2.3683742 2.3505669 1.7213747 0.9259809 1.5967235 1.8222829
DURYER_DYNAMIS 2.5321281 3.2563712 2.2326291 2.0638205 1.6663036 1.7370943 1.7262034
DURYER_ESTHER 2.9122765 2.5985557 2.0894992 2.3262697 1.8290517 1.586362 1.562685
MOLIERE_AMPHITRYON 3.3137427 2.7197699 2.050769 1.4442916 1.5068151 2.1758159 1.4317869
MOLIERE_DOMGARCIEDENAVARRE 3.0433769 2.5303172 2.2854478 1.329291 2.1513526 1.6791045 1.5625
... ... ... ... ... ... ...
la à un il
CORNEILLEP_ANDROMEDE 1.5658398 1.8292986 1.307352 1.3272357 ...
CORNEILLEP_CID 1.3207897 1.8954491 1.3995736 1.3485958 ...
CORNEILLEP_ILLUSIONCOMIQUE 1.2914026 1.4707641 1.53653 1.6321894 ...
CORNEILLEP_MEDEE 1.5771709 2.1172139 1.3930654 1.1660018 ...
DURYER_CLARIGENE 1.2003369 1.2564931 1.7759371 1.488137 ...
DURYER_CLITOPHON 1.5848519 1.317742 1.478008 1.0268891 ...
DURYER_DYNAMIS 1.8296667 1.3232411 1.8351122 1.6118493 ...
DURYER_ESTHER 1.5330887 1.3318338 1.7698591 1.4561383 ...
MOLIERE_AMPHITRYON 1.0941603 1.6631237 1.3942729 1.3817682 ...
MOLIERE_DOMGARCIEDENAVARRE 0.9736474 1.8948228 1.7257463 1.4109142 ...
... ... ... ... ...
(total number of rows/columns: 28/5000)
# je retourne le tableau pour avoir un mot par rang
theatreFrequences<-t(resultats$table.with.all.freqs)
# je ne garde que les 100 premiers mots
head(theatreFrequences[1:100,])
CORNEILLEP_ANDROMEDE CORNEILLEP_CID CORNEILLEP_ILLUSIONCOMIQUE CORNEILLEP_MEDEE DURYER_CLARIGENE
de 3.395138 3.1328205 3.348081 3.602332 2.470869
et 2.888105 2.7110946 2.588784 3.019331 2.583181
que 1.874037 1.7286125 1.757742 1.951519 2.470869
le 1.685142 1.7795903 1.500658 1.288739 1.818054
vous 1.749764 0.8805265 1.745785 1.092360 2.084796
je 1.048864 1.5617759 1.919168 1.552624 1.965464
DURYER_CLITOPHON DURYER_DYNAMIS DURYER_ESTHER MOLIERE_AMPHITRYON MOLIERE_DOMGARCIEDENAVARRE
de 3.3655844 2.532128 2.912277 3.313743 3.043377
et 2.3683742 3.256371 2.598556 2.719770 2.530317
que 2.3505669 2.232629 2.089499 2.050769 2.285448
le 1.7213747 2.063821 2.326270 1.444292 1.329291
vous 0.9259809 1.666304 1.829052 1.506815 2.151353
je 1.5967235 1.737094 1.586362 2.175816 1.679104
MOLIERE_MISANTHROPE MOLIERE_TARTUFFE RACINE_BERENICE RACINE_ESTHER RACINE_IPHIGENIE
de 3.262026 3.138635 3.333333 3.5413770 3.003790
et 3.086420 3.185550 1.983365 2.4657935 2.479938
que 2.059387 1.914145 2.188100 1.4414283 1.983950
le 1.580460 1.505982 1.682662 2.4950611 1.688587
vous 3.091741 3.133943 2.616763 0.9877808 2.574677
je 2.261601 1.904762 2.603967 0.9072949 1.816763
RACINE_PHEDRE ROTROU_COSROES ROTROU_DEUXPUCELLES ROTROU_DOMBERNARDDECABRERE
de 4.0640927 3.169511 3.180893 3.468175
et 2.1786202 3.336327 2.817677 3.245343
que 1.2325527 1.315283 2.080238 1.514113
le 1.9787468 2.033877 1.408838 2.022626
vous 0.9960358 2.572822 1.293269 1.496972
je 1.1459409 1.385859 1.766551 1.091304
ROTROU_HERCULEMOURANT SCARRON_DOMJAPHETDARMENIE SCARRON_ECOLIERDESALAMANQUE
de 3.2294961 3.060230 2.880212
et 3.2833210 2.345527 2.681369
que 1.7089417 1.494380 2.018559
le 1.7358541 2.007667 1.663051
vous 0.5315212 2.033656 2.368040
je 0.9688488 2.429992 2.500603
SCARRON_FAUSSEAPPARENCE SCARRON_GARDIENDESOIMEME SCUDERY_MORTDECESAR SCUDERY_ORANTE
de 2.762744 2.741808 3.495815 2.281265
et 2.441787 2.261536 2.968277 2.322246
que 2.108244 1.866375 2.300063 2.233454
le 1.422278 2.249377 2.377435 2.144662
vous 2.234110 1.969725 1.266090 1.502630
je 2.353682 2.504712 1.259056 2.076361
SCUDERY_PRINCEDEGUISE SCUDERY_VASSALGENEREUX
de 3.284882 2.810734
et 3.092784 2.500000
que 2.298777 2.415254
le 1.991420 2.274011
vous 1.120574 2.175141
je 1.805725 1.631356
#Je peux évidemment tout faire d'un coup:
#theatreFrequences<-t(resultats$table.with.all.freqs)[1:100,]
Je peux désormais contrôler la significativité des axes produits:
if(!require("FactoMineR")){
install.packages("FactoMineR")
library(FactoMineR)
}
Loading required package: FactoMineR
theatreFrequencesPCA = PCA(t(theatreFrequences))
barplot(theatreFrequencesPCA$eig[,1], main="Eigenvalues", names.arg=1:nrow(theatreFrequencesPCA$eig))
Mais nous allons un peu vite: ralentissons un peu, nous reviendrons à ces questions le cours prochain.
##4.2 Principal component analysis (avec correlation)
Il est possible de modifier les résultats afin d’accentuer de manière proportionnelle la distance entre les différents tokens pour “aérer” la partie centrale en modifiant légèrement la méthode de calcul.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 100, mfw.incr=100,
analysis.type = "PCR", distance.measure = "delta",
pca.visual.flavour = "loadings")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
Il est ainsi possible d’associer certains tokens à des auteurs, ou des groupes d’auteurs.
En bas du graphique, on trouve un pourcentage: il nous donne une idée de la distortion apportée au résultat précédent pour accentuer l’espace entre les mots, et donc le degré de fiabilité du résultat. On remarque la correlation a fait perdre de la significativité au premier axe.
##4.3 Multidimensional scaling
Un mode de visualisation des données assez commun est le Multidimensional scaling (“positionnement multidimensionnel” en français). Pour faire (très, très) simple, il s’agit de spatialiser les résultats.
stylo(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 100, mfw.max = 100, mfw.incr=100,
analysis.type = "MDS", distance.measure = "wurzburg",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
MFW used:
100
Processing metadata...
Assigning plot colors according to file names...
Un des intérêts de ce type de visualisation est d’identifier les auteurs avec les styles les plus neutres, et ceux avec les styles les plus marqués.
#Conclusion: vers l’analyse de réseau
if(!require("networkD3")){
install.packages("networkD3")
library("networkD3")
}
Loading required package: networkD3
stylo.network(gui=FALSE, corpus.dir = "corpus",
corpus.format = "xml.drama", corpus.lang = "French",
analyzed.features = "w", mfw.min = 1700, mfw.max = 100, mfw.incr=100,
analysis.type = "CA", distance.measure = "wurzburg",
pca.visual.flavour = "classic")
using current directory...
Performing no sampling (using entire text as sample)
loading CORNEILLEP_ANDROMEDE.xml ...
loading CORNEILLEP_CID.xml ...
loading CORNEILLEP_ILLUSIONCOMIQUE.xml ...
loading CORNEILLEP_MEDEE.xml ...
loading DURYER_CLARIGENE.xml ...
loading DURYER_CLITOPHON.xml ...
loading DURYER_DYNAMIS.xml ...
loading DURYER_ESTHER.xml ...
loading MOLIERE_AMPHITRYON.xml ...
loading MOLIERE_DOMGARCIEDENAVARRE.xml ...
loading MOLIERE_MISANTHROPE.xml ...
loading MOLIERE_TARTUFFE.xml ...
loading RACINE_BERENICE.xml ...
loading RACINE_ESTHER.xml ...
loading RACINE_IPHIGENIE.xml ...
loading RACINE_PHEDRE.xml ...
loading ROTROU_COSROES.xml ...
loading ROTROU_DEUXPUCELLES.xml ...
loading ROTROU_DOMBERNARDDECABRERE.xml ...
loading ROTROU_HERCULEMOURANT.xml ...
loading SCARRON_DOMJAPHETDARMENIE.xml ...
loading SCARRON_ECOLIERDESALAMANQUE.xml ...
loading SCARRON_FAUSSEAPPARENCE.xml ...
loading SCARRON_GARDIENDESOIMEME.xml ...
loading SCUDERY_MORTDECESAR.xml ...
loading SCUDERY_ORANTE.xml ...
loading SCUDERY_PRINCEDEGUISE.xml ...
loading SCUDERY_VASSALGENEREUX.xml ...
slicing input text into tokens...
turning words into features, e.g. char n-grams (if applicable)...
Total nr. of samples in the corpus: 28
.........................
...
The corpus consists of 480663 tokens
processing 28 text samples
..
combining frequencies into a table...
culling @ 0 available features (words) 5000
Calculating z-scores...
MFW used:
1700
Processing metadata...
Assigning plot colors according to file names...
SORRY, BUT YOU ARE EXPECTING TOO MUCH...!
There should be at least 3 iterations to make a consensus tree